﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Language Class - Fuel Documentation</title>
	<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../assets/js/nav.js"></script>
	<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>Fuel Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Lang Class</h2>

		<p>The Lang class allows you to set language variables using language files in your application.</p>

		<article>
			<h4 id="method_load">load($file, $group = null)</h4>
			<p>The <strong>load</strong> method allows you to load a language file.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$file</kbd></th>
								<td><i>required</i></td>
								<td>The path of the desired file. You can prefix this with a namespace to load a config file from a loaded package or module.</td>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><pre class="php"><code>null</code></pre></td>
								<td>Sets a language group to be used.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>void</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Example of a language file:
return array(
	'hello' => 'Hello :name',
	'something'=> 'something :name!',
	'test'=> array('hello' => 'Hello', 'something' => 'Plop') // Group
);

// Loads example.php.
// Note: If no language is set in the config, it will fallback to English.
Lang::load('example');

// Will load the given file into the 'test' group.
Lang:load('example', 'test');

// Outputs Plop
$this->output = Lang::line('test.test.something');

// Will load the example language file from the module 'foo' into the 'bar' group.
Lang:load('foo::example', 'bar');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_line">line($line, $params = array())</h4>
			<p>The <strong>line</strong> method allows you to get a specific line from the language file.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$line</kbd></th>
								<td><i>required</i></td>
								<td>The desired line's identifier.</td>
							</tr>
							<tr>
								<th><kbd>$parameters</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>Sets an array of parameter that might be passed to the line.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Outputs Hello world
$this->output = Lang::line('hello', array('name' => 'world');

// Outputs Plop
$this->output = Lang::line('test.something');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_set">set($line, $value, $group = null)</h4>
			<p>The <strong>set</strong> method allows you to set a specific line to the language file.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$line</kbd></th>
								<td><i>required</i></td>
								<td>The desired line's identifier.</td>
							</tr>
							<tr>
								<th><kbd>$value</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>Sets the value of the line.</td>
							</tr>
							<tr>
								<th><kbd>$group</kbd></th>
								<td><pre class="php"><code>null</code></pre></td>
								<td>Sets a language group to be used.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>boolean</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Returns true
Lang::set('hello', 'Ahoy!');

// Using groups
Lang:set('hello', 'Ahoy!', 'test');

// Will also work as above
Lang::load('test', 'test);
Lang::set('hello', 'Ahoy!');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<h3 id="procedural_helpers">Procedural helpers</h3>

		<article>
			<h4 id="function___">__($string, $params = array())</h4>
			<p>The <strong>__</strong> function is an alias for <a href="#method_line">Lang::line</a>.</p>
			<table class="method">
				<tbody>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$string</kbd></th>
								<td><i>required</i></td>
								<td>The desired line's identifier.</td>
							</tr>
							<tr>
								<th><kbd>$parameters</kbd></th>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>Sets an array of parameter that might be passed to the line.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>string, result from <a href="#method_line">Lang::line</a></td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Outputs Hello world
$this->output = __('hello', array('name' => 'world');

// Outputs Plop
$this->output = __('test.something');</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

	</section>

	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
			© 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>
